﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GEMINI_OP10
{
    public partial class FormManMode : Form
    {
        public FormManMode()
        {
            InitializeComponent();
        }
        //静音按钮
        private void button2_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX0.2", !FormMain.PLC_Link[1].readBoolen("DB1050.DBX0.2"));
        }
        //工位屏蔽按钮
        private void button3_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX0.3", !FormMain.PLC_Link[1].readBoolen("DB1050.DBX0.3"));
        }
        //RFID屏蔽按钮
        private void button4_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX0.4", !FormMain.PLC_Link[1].readBoolen("DB1050.DBX0.4"));
        }
        //相机屏蔽按钮
        private void button5_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX0.5", !FormMain.PLC_Link[1].readBoolen("DB1050.DBX0.5"));
        }
        //扫码屏蔽按钮
        private void button6_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX0.6", !FormMain.PLC_Link[1].readBoolen("DB1050.DBX0.6"));
        }
        //拧紧枪1屏蔽按钮
        private void button7_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX0.7", !FormMain.PLC_Link[1].readBoolen("DB1050.DBX0.7"));
        }
        //拧紧枪2屏蔽按钮
        private void button8_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX1.0", !FormMain.PLC_Link[1].readBoolen("DB1050.DBX1.0"));
        }
        //返回原位按钮
        private void button9_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX1.1", true);
        }
        private void button9_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX1.1", false);
        }
        //复位按钮
        private void button10_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX1.2", true);
        }

        private void button10_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX1.2", false);
        }
        //防螺钉掉落屏蔽按钮1
        private void button11_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX2.5", !FormMain.PLC_Link[1].readBoolen("DB1050.DBX2.5"));
        }
        //返修按钮
        private void button12_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX1.4", !FormMain.PLC_Link[1].readBoolen("DB1050.DBX1.4"));
        }
        //强制不合格按钮
        private void button13_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX1.5", true);
        }

        private void button13_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX1.5", false);
        }
        //空托盘按钮
        private void button14_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX1.6", !FormMain.PLC_Link[1].readBoolen("DB1050.DBX1.6"));
        }
        //放行按钮
        private void button15_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX1.7", true);
        }

        private void button15_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX1.7", false);
        }
        //状态
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX0.2"))
            {
                button2.BackColor = Color.Green;    //静音
            }
            else
            {
                button2.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX0.3"))
            {
                button3.BackColor = Color.Green;    //工位屏蔽
            }
            else
            {
                button3.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX0.4"))
            {
                button4.BackColor = Color.Green;    //RFID屏蔽
            }
            else
            {
                button4.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX0.5"))
            {
                button5.BackColor = Color.Green;    //相机屏蔽
            }
            else
            {
                button5.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX0.6"))
            {
                button6.BackColor = Color.Green;    //扫码屏蔽
            }
            else
            {
                button6.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX0.7"))
            {
                button7.BackColor = Color.Green;    //拧紧枪屏蔽1
            }
            else
            {
                button7.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX1.0"))
            {
                button8.BackColor = Color.Green;    //拧紧枪屏蔽2
            }
            else
            {
                button8.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX1.1"))
            {
                button9.BackColor = Color.Green;    //返回原位
            }
            else
            {
                button9.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX1.2"))
            {
                button10.BackColor = Color.Green;   //复位
            }
            else
            {
                button10.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX2.5"))
            {
                button11.BackColor = Color.Green;   //防螺钉掉入屏蔽1
            }
            else
            {
                button11.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX1.4"))
            {
                button12.BackColor = Color.Green;   //返修件
            }
            else
            {
                button12.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX1.5"))
            {
                button13.BackColor = Color.Green;   //强制不合格
            }
            else
            {
                button13.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX1.6"))
            {
                button14.BackColor = Color.Green;   //空托盘
            }
            else
            {
                button14.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX1.7"))
            {
                button15.BackColor = Color.Green;   //放行
            }
            else
            {
                button15.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX28.0"))
            {
                button1.BackColor = Color.Green;    //顶升气缸伸出
            }
            else
            {
                button1.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX28.1"))
            {
                button16.BackColor = Color.Green;   //顶升气缸缩回
            }
            else
            {
                button16.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX32.0"))
            {
                button17.BackColor = Color.Green;   //OP10移栽气缸伸出
            }
            else
            {
                button17.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX32.1"))
            {
                button18.BackColor = Color.Green;   //OP10移栽气缸缩回
            }
            else
            {
                button18.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX2.1"))
            {
                button19.BackColor = Color.Green;   //OP10挡停打开
            }
            else
            {
                button19.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX30.0"))
            {
                button20.BackColor = Color.Green;   //OP100移栽气缸伸出
            }
            else
            {
                button20.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX30.1"))
            {
                button21.BackColor = Color.Green;   //OP100移栽气缸缩回
            }
            else
            {
                button21.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX1.3"))
            {
                button22.BackColor = Color.Green;   //测试上线
            }
            else
            {
                button22.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX34.0"))
            {
                button24.BackColor = Color.Green;   //翻转气缸伸出到位
            }
            else
            {
                button24.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX34.1"))
            {
                button23.BackColor = Color.Green;   //翻转气缸缩回到位
            }
            else
            {
                button23.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[1].readBoolen("DB1050.DBX12.0"))
            {
                button25.BackColor = Color.Green;   //气压表伸出
            }
            else
            {
                button25.BackColor = Color.Silver;
            }

        }
        //顶升气缸伸出按钮
        private void button1_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX4.0", true);
        }

        private void button1_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX4.0", false);
        }
        //顶升气缸缩回按钮
        private void button16_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX4.1", true);
        }

        private void button16_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX4.1", false);
        }
        //OP10移栽气缸伸出按钮
        private void button17_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX8.0", true);
        }

        private void button17_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX8.0", false);
        }
        //OP10移栽气缸缩回按钮
        private void button18_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX8.1", true);
        }

        private void button18_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX8.1", false);
        }
        //OP10挡停打开
        private void button19_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX2.1", true);
        }

        private void button19_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX2.1", false);
        }
        //OP100移栽气缸伸出按钮
        private void button20_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX6.0", true);
        }

        private void button20_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX6.0", false);
        }
        //OP100移栽气缸缩回按钮
        private void button21_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX6.1", true);
        }

        private void button21_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX6.1", false);
        }
        //测试上线按钮
        private void button22_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX1.3", !FormMain.PLC_Link[1].readBoolen("DB1050.DBX1.3"));
        }
        //翻转气缸伸出
        private void button24_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX10.0", true);
        }
        private void button24_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX10.0", false);
        }
        //翻转气缸缩回
        private void button23_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX10.1", true);
        }
        private void button23_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX10.1", false);
        }
        
        //private void button25_MouseDown(object sender, MouseEventArgs e)
        //{
        //    FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX12.0", true);
        //}
        //private void button25_MouseUp(object sender, MouseEventArgs e)
        //{
        //    FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX12.0", true);
        //}
        //气压表伸出
        private void button25_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[1].WriteBoolen("DB1050.DBX12.0", !FormMain.PLC_Link[1].readBoolen("DB1050.DBX12.0"));
        }
    }
}
